Move the translation from pages to MiB out of XendNode and into the xc layer.
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 30 Nov 2005 18:43:00 +0000 (18:43 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 30 Nov 2005 18:43:00 +0000 (18:43 +0000)
xc has access to the page size for the platform and the Python layer does not,
so there was a hardcoded "/ 256" in there.

Rename the "memory" physinfo parameter to "total_memory", to match the usage
elsewhere.

Tidy the code generating the SXP for xm info.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/xend/XendNode.py
tools/xm-test/lib/XmTestReport/OSReport.py

index c63968f424368930304f59b9f6a821fe1c9212e8..29f64641d685cd692a62edbc85bf75f5ed9f71cd 100644 (file)
@@ -575,6 +575,13 @@ static PyObject *pyxc_readconsolering(XcObject *self,
     return PyString_FromStringAndSize(str, count);
 }
 
+
+static unsigned long pages_to_mb(unsigned long pages)
+{
+    return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
+}
+
+
 static PyObject *pyxc_physinfo(XcObject *self)
 {
     xc_physinfo_t info;
@@ -599,8 +606,8 @@ static PyObject *pyxc_physinfo(XcObject *self)
                          "cores_per_socket", info.cores_per_socket,
                          "sockets_per_node", info.sockets_per_node,
                          "nr_nodes",         info.nr_nodes,
-                         "total_pages",      info.total_pages,
-                         "free_pages",       info.free_pages,
+                         "total_memory",     pages_to_mb(info.total_pages),
+                         "free_memory",      pages_to_mb(info.free_pages),
                          "cpu_khz",          info.cpu_khz,
                          "hw_caps",          cpu_cap);
 }
index 250d11cecedcd63ecd6741014dfeece7ca5d1850..02899bec2765525ef08e57e6c9181381744ef427 100644 (file)
@@ -57,30 +57,45 @@ class XendNode:
                 ['machine', mch]]
 
     def physinfo(self):
-        pinfo = self.xc.physinfo()
-        info = [['nr_cpus',          pinfo['nr_nodes']*pinfo['sockets_per_node']*pinfo['cores_per_socket']*pinfo['threads_per_core']],
-                ['nr_nodes',         pinfo['nr_nodes']],
-                ['sockets_per_node', pinfo['sockets_per_node']],
-                ['cores_per_socket', pinfo['cores_per_socket']],
-                ['threads_per_core', pinfo['threads_per_core']],
-                ['cpu_mhz',          pinfo['cpu_khz']/1000],
-                ['hw_caps',          pinfo['hw_caps']],
-                ['memory',           pinfo['total_pages']/256],
-                ['free_memory',      pinfo['free_pages']/256]]
-        return info
-        
+        info = self.xc.physinfo()
+
+        info['nr_cpus'] = (info['nr_nodes'] *
+                           info['sockets_per_node'] *
+                           info['cores_per_socket'] *
+                           info['threads_per_core'])
+        info['cpu_mhz'] = info['cpu_khz'] / 1000
+
+        ITEM_ORDER = ['nr_cpus',
+                      'nr_nodes',
+                      'sockets_per_node',
+                      'cores_per_socket',
+                      'threads_per_core',
+                      'cpu_mhz',
+                      'hw_caps',
+                      'total_memory',
+                      'free_memory',
+                      ]
+
+        return [[k, info[k]] for k in ITEM_ORDER]
+
+
     def xeninfo(self):
-        xinfo = self.xc.xeninfo()
-        return [['xen_major', xinfo['xen_major']],
-                ['xen_minor', xinfo['xen_minor']],
-                ['xen_extra', xinfo['xen_extra']],
-                ['xen_caps',  xinfo['xen_caps']],
-                ['platform_params',xinfo['platform_params']],
-                ['xen_changeset', xinfo['xen_changeset']],
-                ['cc_compiler', xinfo['cc_compiler']],
-                ['cc_compile_by', xinfo['cc_compile_by']],
-                ['cc_compile_domain', xinfo['cc_compile_domain']],
-                ['cc_compile_date', xinfo['cc_compile_date']]]
+        info = self.xc.xeninfo()
+
+        ITEM_ORDER = ['xen_major',
+                      'xen_minor',
+                      'xen_extra',
+                      'xen_caps',
+                      'platform_params',
+                      'xen_changeset',
+                      'cc_compiler',
+                      'cc_compile_by',
+                      'cc_compile_domain',
+                      'cc_compile_date',
+                      ]
+
+        return [[k, info[k]] for k in ITEM_ORDER]
+
 
 def instance():
     global inst
index c1d94b9774f4761c140bf13481895aa626fbd336..dff20399e260817048d914d203a2aba35b472ed2 100644 (file)
@@ -97,7 +97,7 @@ class Machine:
                      "cores_per_socket" : "Unknown",
                      "threads_per_core" : "Unknown",
                      "cpu_mhz"          : "Unknown",
-                     "memory"           : "Unknown"}
+                     "total_memory"     : "Unknown"}
 
         xen = self.__getXenInfo(xenValues)
         cpu = self.__getCpuInfo(cpuValues)